package com.linghui.videoplus.ipai.activity;

import java.util.concurrent.Callable;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import com.linghui.videoplus.ipai.VideoPlusApplication;
import com.linghui.videoplus.ipai.api.async.AsyncUtils;
import com.linghui.videoplus.ipai.api.async.Callback;
import com.linghui.videoplus.ipai.api.async.ProgressCallable;
import com.linghui.videoplus.ipai.view.MenuLayout;

public class BaseActivity extends Activity {
	protected MenuLayout menuLayout;
	protected int FROM_CODE=0;
	protected int TO_CODE=0;
	
	public static final int REQUEST_CODE_DEFAULT = 1000;
	public static final int REQUEST_CODE_CAMERA = 1001;
	public static final int REQUEST_CODE_VIDEO_CASCADE= 1002;
	public static final int REQUEST_CODE_MY_VIDEO=1003;
	public static final int REQUEST_CODE_SAVE_VIDEO=1004;
	public static final int REQUEST_CODE_INIT=1005;
	public static final int REQUEST_CODE_UPLOAD=1006;
	public static final int REQUEST_CODE_ACCOUNT=1007;
	public static final int REQUEST_CODE_NETWORK_ERROR=1008;
	public static final int REQUEST_CODE_SETTING=1009;
	
	
	public static final String FROM_CODE_KEY="FROM_CODE_KEY";
	public static final String TO_CODE_KEY="TO_CODE_KEY";
	public static final String SERIALIZABLE__KEY="SERIALIZABLE__KEY";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		VideoPlusApplication.sAllActivity.add(this);
	}

	
	/**
	 * 显示浮动窗体消息通知, 时间短
	 * 
	 * @param msg
	 */
	public void showToast(String msg) {
		Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
	}
	
	
	protected <T> void doProgressDialogAsync(final ProgressCallable<T> pCallable, final Callback<T> pCallback) {
		this.doProgressDialogAsync(pCallable, pCallback, null);
	}
	protected <T> void doProgressDialogAsync(final ProgressCallable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) {
		AsyncUtils.doProgressDialogAsync(this, pCallable, pCallback, pExceptionCallback);
	}
	protected <T> void doAsync(final Callable<T> pCallable, final Callback<T> pCallback) {
		AsyncUtils.doAsync(this, null, "内容读取中，请稍等...", pCallable, pCallback, null, false);
	}
	
}
